<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/drag/drag.css"  media="all">
    <style>
        .box{
            margin-top:20px;
            margin-bottom:10px;
        }
        #productPricing tr th,td{
            text-align:center
        }
        .required_text{
           color:red;
            padding: 8px;
        }
        #sourceBox{
            margin-bottom: 15px;
        }
        .list-group-item{
            margin: 5px 30px 5px 0;
            color: #212529;
            display: inline-block;
        }
        .list-group-item>i{
            color:red;
        }
    </style>
</head>
<body>

<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <!--基础信息-->
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    <h2>基础信息</h2>
                </div>
                <div class="layui-card-body">
                    <div class="box">
                        <div style="margin-left:20px;">
                            <form class="layui-form" id="basic">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">标品名称<br>（限63字）</label>
                                    <div class="layui-input-inline" style="width: 600px">
                                        <input maxlength="63" id="standardNmae" name="name" lay-verify="required" {notempty name="$info.name"}value="{$info.name}"{/notempty} placeholder="请输入名称" autocomplete="off" class="layui-input" type="text">
                                    </div>
                                </div>
                                {if empty($info.type) || $info.type==2}
                                <!--提前截止售卖天数-->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">提前截止售卖天数</label>
                                    <div class="layui-input-inline" style="width: 200px">
                                        <input name="s_endDays" lay-verify="required" {if isset($info.s_endDays)}value="{$info.s_endDays}"{/if} placeholder="请输入提前截止售卖天数" autocomplete="off" class="layui-input" type="number">
                                    </div>
                                </div>
                                {/if}
                                <div class="layui-form-item">
                                    <label class="layui-form-label">允许其他分销商采购</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="allow_everyone_quote" value="1" title="是" {notempty name="$info.allow_everyone_quote"}{if $info.allow_everyone_quote==1}checked{/if}{/notempty}>
                                        <input type="radio" name="allow_everyone_quote" value="0" title="否" {empty name="$info.allow_everyone_quote"}checked{/empty}>
                                    </div>
                                </div>

                                <div class="layui-form-item layui-form-text" style="position: relative ;z-index: 98">
                                    <label class="layui-form-label">副标题<br>(30字)</label>
                                    <div class="layui-input-block" style="max-width:500px;">
                                        <textarea placeholder="请输入副标题" class="layui-textarea" id="introduce" name="introduce" maxlength="30">{notempty name="$info.introduce"}{$info.introduce}{/notempty}</textarea>
                                    </div>
                                </div>

                                <input type="hidden" class="standard_id" name="id" {notempty name='$info'}value="{$info.id}"{/notempty}>

                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn layui-btn-radius" lay-submit lay-filter="basic">保存</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--多选标签-->
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    <h2 class="layui-inline">选择分类</h2>
                    <p class="layui-inline" style="margin-left: 20px;color:palevioletred">【已选详细分类】支持拖拽排序！优先使用靠前的分类进行显示</p>
                </div>
                <div class="layui-card-body">
                    <div class="box">
                        <div style="margin-left:20px;">
                            <form class="layui-form" id="tagForm">
                                <!--顶级分类-->
                                <!--<div class="layui-form-item" id="topCategory">-->
                                    <!--<label class="layui-form-label">顶级分类</label>-->
                                    <!--<div class="layui-input-inline" style="width: 400px">-->
                                        <!--<select name="topCate" id="topCate" lay-filter="topCate" lay-search>-->
                                            <!--<option value="">请选择顶级分类</option>-->
                                            <!--{notempty name="$topCate"}-->
                                            <!--{volist name="topCate" id="vo"}-->
                                            <!--<option value="{$vo.id}" {notempty name="$info.topCate"}{if $info['topCate']==$vo['id']}selected{/if}{/notempty}>{$vo.name}</option>-->
                                            <!--{/volist}-->
                                            <!--{/notempty}-->
                                        <!--</select>-->
                                    <!--</div>-->
                                <!--</div>-->
                                <!--详细分类[多选]-->
                                <div class="layui-form-item" id="firstCategory">
                                    <label class="layui-form-label">详细分类<br>[多选]</label>
                                    <div class="layui-input-inline" style="width: 400px">
                                        <select name="categorytagid" id="categorytags" lay-filter="addCategoryTags" lay-search>
                                            <option value="">请选择详细分类</option>
                                            <!--初始化-->
                                            {notempty name="$tags"}
                                            {volist name="tags" id="cate"}
                                            <option value="{$cate.tag_id}">{$cate.tag_name}</option>
                                            {/volist}
                                            {/notmepty}
                                        </select>
                                    </div>
                                </div>
                                <!--已选详细分类-->
                                <div class="layui-form-item" >
                                    <label class="layui-form-label">已选<br>详细分类</label>
                                    <div class="layui-input-inline" style="width: 400px">
                                        <blockquote class="layui-elem-quote elem-quote-div">
                                            <div id="shared-lists" class="shared-lists">
                                                <div class="boxcont" id="boxcont">
                                                    <div id="sortTags" class="example2 schedule_div" style="padding:15px;">
                                                        {notempty name="$tagsData"}
                                                        {volist name="tagsData" id="tag"}
                                                        <span class="list-group-item list-group-{$tag.tagid}" value="{$tag.tagid}" id="{$tag.tagid}">{$tag.tag_name}<i class="layui-icon">&#x1006;</i></span>
                                                        {/volist}
                                                        {/notempty}
                                                    </div>
                                                </div>
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                                <input type="hidden" name="standard_id" value="{notempty name='$info'}{$info.id}{/notempty}">
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn layui-btn-radius" lay-submit lay-filter="tagForm">保存</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--资源-->
        <div class="layui-col-md12" id="sourceBox">
            <div class="layui-card">
                <div class="layui-card-header">
                    <h2>商品</h2>
                </div>
                <div class="layui-card-body">
                    <div class="box">
                        <div>
                            <form class="layui-form" id="source">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">关联商品</label>
                                    <div class="layui-input-inline" style="width: 600px">
                                        <select id="addGoods" name="goods_id" lay-filter="addGoods" lay-search>
                                            <option value="">请填写商品名称</option>
                                            {if !empty($info.goods_id)}
                                            <option value="{$goodsData.goods_id}" selected="selected">{$goodsData.goods_name}</option>
                                            {/if}
                                        </select>
                                    </div>
                                    <button class="layui-btn layui-btn-danger layui-btn-radius" lay-submit lay-filter="source">保存</button>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">订单类型</label>
                                    <div class="layui-input-inline" style="width: 800px">
                                        <input class="layui-input" readonly style="width:190px;" type="text" value="{notempty name='$goodsData.orderTypeTitle'}{$goodsData.orderTypeTitle}{/notempty}">
                                    </div>
                                </div>
                                <!--<div class="layui-form-item">-->
                                    <!--<label class="layui-form-label">价格配置</label>-->
                                    <!--<div class="layui-input-inline" style="width: 800px">-->
                                        <!--&lt;!&ndash;<a href="{:url('admin/goods/addclassify')}" class="layui-btn layui-btn-warm addclassify"  style="margin-right: 0;margin-top:2px;font-size:12px;background: #51a954">商品套餐</a>&ndash;&gt;-->
                                        <!--&lt;!&ndash;<a href="{:url('admin/goods/setgoodsprice')}" class="layui-btn layui-btn-warm setgoodsprice"  style="margin-right: 0;margin-top:2px;font-size:12px;background: darkslategrey">商品价格</a>&ndash;&gt;-->
                                        <!--<a href="{:url('admin/goods/setgoodscartype')}" class="layui-btn layui-btn-warm setgoodscartype"  style="margin-right: 0;margin-top:2px;font-size:12px;background: #1e9fff">套餐车型</a>-->
                                    <!--</div>-->
                                <!--</div>-->

                                <input type="hidden" class="standard_id" name="id" {notempty name='$info'}value="{$info.id}"{/notempty}>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--产品-->
        <div class="layui-col-md12" id="tripBox" style="{if !empty($info.type)&&$info.type==2}display:none{/if}">
            <div class="layui-card">
                <div class="layui-card-header">
                    <h2>产品</h2>
                </div>
                <div class="layui-card-body">
                    <div class="box">
                        <div style="margin-left:20px;">
                            <form class="layui-form" id="trip">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"><span class="required_text">*</span>产品名称</label>
                                    <div class="layui-input-inline" style="width: 600px">
                                        <select id="addTrip" name="trip_id" lay-verify="required" lay-filter="addTrip" lay-search>
                                            <option value="">请填写产品名称</option>
                                            {if !empty($tripArr)}
                                            <option value="{$tripArr.id}" selected="selected">{$tripArr.name}</option>
                                            {/if}
                                        </select>
                                    </div>
                                    {notempty name='$tripData.section_json'}
                                    <span>
                                        <a class="layui-btn layui-btn-sm layui-btn-info setSection" style="margin-top:4px;">分段配置</a>
                                    </span>
                                    {/notempty}
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">起始城市</label>
                                    <div class="layui-input-inline" style="width: 400px">
                                        <select name="startCityId" lay-filter="startCityId" lay-search>
                                            <option value="">请选择城市</option>
                                            {notempty name="$city"}
                                            {volist name="$city" id="vo"}
                                            <option {notempty name='$tripData.startCityId'}{if $vo.id==$tripData.startCityId} selected{/if}{/notempty} value="{$vo.id}">{$vo.name}({$vo.eng_name})</option>
                                            {/volist}
                                            {/notempty}
                                        </select>
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">售卖截止天数</label>
                                    <div class="layui-input-inline" style="width: 150px">
                                        <input name="endDays" {notempty name="$tripData"}value="{$tripData.endDays}"{/notempty} placeholder="请输入数字" autocomplete="off" class="layui-input" type="number">
                                    </div>
                                </div>

                                <div class="layui-form-item layui-form-text" style="position: relative ;z-index: 98;">
                                    <label class="layui-form-label">行程介绍</label>
                                    <div class="layui-input-block" style="max-width:500px;">
                                        <textarea placeholder="此处主要描述客户行程路线计划，对客户和服务伙伴可见，不要放敏感信息。" style="height:250px;" id="toursLineTitle" class="layui-textarea" name="toursLineTitle">{notempty name="$tripData.toursLineTitle"}{$tripData.toursLineTitle}{/notempty}</textarea>
                                    </div>
                                </div>

                                <div class="layui-form-item layui-form-text" style="position: relative ;z-index: 98">
                                    <label class="layui-form-label">特殊说明</label>
                                    <div class="layui-input-block" style="max-width:500px;">
                                        <textarea placeholder="特殊说明： 给司导的特殊提示信息，客户不可见。参考内容：客户对气味比较敏感，车里不能有异味。" class="layui-textarea" name="specialInfo">{notempty name="$tripData.specialInfo"}{$tripData.specialInfo}{/notempty}</textarea>
                                    </div>
                                </div>
                                <input type="hidden" class="standard_id" name="id" {notempty name='$info'}value="{$info.id}"{/notempty}>

                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn layui-btn-radius" lay-submit lay-filter="trip">保存</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script src="__PUBLIC__/drag/Sortable.js"></script>
<script>
    $('.example2').each(function () {
        new Sortable( document.getElementById("sortTags"), {
            group: 'shared',
            animation: 150,
            scroll:true,
            forceFallback: true,
            onEnd:function (evt) {
                var schedule_id = evt.to.id;
                var one1=evt.item.id
                var str = '';
                $("#"+schedule_id).find(".list-group-item").each(function(){
                    str += ","+$(this).attr("id");
                });
                console.log(evt.to.id,evt.item.id,str)
                return false;
            }
        });
    });

    $(document).on('click','.list-group-item i',function () {
        $(this).parent().remove();
    })
</script>
<script>
    layui.use(['element','layer', 'form'], function() {
        var layer = layui.layer,
            element = layui.element,
            $ = layui.jquery,
            form = layui.form;
        //打开核价页面
        $(".openPricing").click(function(){
            var id = $("#addTrip").val();
            if(id=="" || id==null || id==undefined){
                layer.msg('请先选择产品！');return false;
            }
            url = "{:url('admin/standard/productpricing')}?id="+id;
            layer.open({
                type:2,
                content:url,
                area: ['100%', '100%'],
                end:function(){
                    location.reload();
                }
            });
        });
        ///打开分段配置页面
        $(".setSection").click(function(){
            var id = $("#addTrip").val();
            var standard_id = $(".standard_id").val();
            if(id=="" || id==null || id==undefined){
                layer.msg('请先选择产品！');return false;
            }
            url = "{:url('admin/product/setSection')}?id="+standard_id;
            layer.open({
                type:2,
                content:url,
                area: ['80%', '90%'],
                end:function(){
                    location.reload();
                }
            });
        });
        //设置标签
//        form.on('select(topCate)',function(data){
//            var value = data.value;
//            var subCates = [];
//            $.each(topCates,function (i,v) {
//                if(v.id==value){
//                    subCates = v.subCates;return false;
//                }
//            })
//            console.log(subCates);
//            var str = '';
//            $.each(subCates,function(i,v){
//                str += "<option value='"+v.tag_id+"'>"+v.tag_name+"</option>";
//            });
//            $("#categorytags option:not(:first-child)").remove();
//            $("#categorytags").append(str);
//            $("#sortTags").children().remove();
//            form.render('select');
//        });
        //***************************************************************************
        //基础信息提交
        form.on('submit(basic)', function() {
            var standardNmae = $("#standardNmae").val();
            if(standardNmae==''){
                layer.msg("请补全标品名称");
                return false;
            }

            $.ajax({
                url:"{:url('admin/standard/submitBasicData')}",
                data:$('#basic').serialize(),
                type:'post',
                async: false,
                success:function(res) {
                    var id = res.data.id;
                    if(id > 0){
                        $(".standard_id").attr("value",id);
                    }
                    console.log(res);
                    layer.msg(res.msg);
                    return false;
                }
            });
            return false;
        });
        //标签提交
        form.on('submit(tagForm)', function() {
            //获取请求参数
            var id = $("#tagForm input[name=standard_id]").val();
            if(id=="" || id==undefined){layer.msg('请刷新页面后重试！');return false;}
            var subCates = [];
            $.each($("#sortTags .list-group-item"),function (i,v) {
                if($(v).attr('value')!==""){
                    subCates.push($(v).attr('value'));
                }
            })
            if(subCates.length < 1){layer.msg('请选择详细分类！');return false;}

            $.ajax({
                url:"{:url('admin/standard/submitTagData')}",
                data:{id:id,subCates:subCates},
                type:'post',
                async: false,
                success:function(res) {
                    console.log(res);
                    layer.msg(res.msg);
                    return false;
                }
            });
            return false;
        });
        //资源信息提交
        form.on('submit(source)', function() {
            $.ajax({
                url:"{:url('admin/standard/submitSourceData')}",
                data:$('#source').serialize(),
                type:'post',
                async: false,
                success:function(res) {
                    console.log(res);
                    layer.msg(res.msg);
                    return false;
                }
            });
            return false;
        });
        //行程信息提交
        form.on('submit(trip)', function() {
            $.ajax({
                url:"{:url('admin/standard/submitTripData')}",
                data:$('#trip').serialize(),
                type:'post',
                async: false,
                success:function(res) {
                    console.log(res);
                    layer.msg(res.msg);
                    setTimeout(function(){
                        window.location.reload();
                    },1000)
                }
            });
            return false;
        });


        $('.addclassify').click(function(){
            var goods_id = $("#addGoods").val();
            if(goods_id==''){
                layer.msg("请选择商品");
                return false;
            }
            var url = $(this).attr('href');
            url = url+"?id="+goods_id;
            layer.open({
                type:2,
                content:url,
                area: ['80%', '90%'],
                end:function(){
                    location.reload();
                }
            });
            return false;
        });
        $('.setgoodsprice').click(function(){
            var goods_id = $("#addGoods").val();
            var standard_id = "{$info.id}";
            if(goods_id==''){
                layer.msg("请选择商品");
                return false;
            }
            var url = $(this).attr('href');
            url = url+"?id="+goods_id+"&standard_id="+standard_id;
            layer.open({
                type:2,
                content:url,
                area: ['80%', '90%'],
                end:function(){
                    location.reload();
                }
            });
            return false;
        });
        $('.setgoodscartype').click(function(){
            var goods_id = $("#addGoods").val();
            if(goods_id==''){
                layer.msg("请选择商品");
                return false;
            }
            var url = $(this).attr('href');
            url = url+"?id="+goods_id;
            layer.open({
                type:2,
                content:url,
                area: ['95%', '95%'],
                end:function(){
                    location.reload();
                }
            });
            return false;
        });
        //***************************************************************************
        //首页分类标签选择
        form.on('select(addCategoryTags)', function(data){
            //添加内容到拖拽框
            var tagId = data.value;
            var tagName = $(this).text();
            if(tagId=="" || tagId==undefined){return false;}
            //判断是否已存在
            var isExistId = false;
            $.each($("#sortTags .list-group-item"),function (i,v) {
                if($(v).attr("value")==tagId){
                    isExistId = true;layer.msg('请勿重复选择');return false;
                }
            })
            if(isExistId){return false;}
            $("#sortTags").append('<span class="list-group-item list-group-'+tagId+'" value="'+tagId+'" id="'+tagId+'">'+tagName+'<i class="layui-icon">&#x1006;</i></span>');
        });
        //***************************************************************************
        //文件上传
        layui.use('upload', function(){
            var upload = layui.upload;
            //上传列表展示图
            var uploadInst = upload.render({
                elem: '#thumb' //绑定元素
                ,url: "{:url('common/upload')}" //上传接口
                ,data:{use:'grouptours_thumb'}
                ,accept: 'images'
                ,done: function(res){
                    //上传完毕回调
                    layer.closeAll('loading');
                    if(res.code == 2) {
                        $('#demo1').attr('src',res.src);
                        $('#upload-thumb').append('<input type="hidden" name="showImg" value="'+ res.src +'">');
                    } else {
                        layer.msg(res.msg);
                    }
                }
                ,error: function(){
                    //请求异常回调
                    //演示失败状态，并实现重传
                    layer.closeAll('loading');
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
                ,before:function () {
                    layer.load(2);
                }
            });
            //执行实例图片
            upload.render({
                elem: '#upload1'
                ,url: "{:url('common/upload')}"
                ,multiple: true
                ,accept:"images"
                ,size:"50000"
                ,done: function(res){
                    //上传完毕回调
                    layer.closeAll('loading');
                    if(res.code == 2) {
                        $('#seeupload1').append('<span class="uploadimgbox"><img class="layui-upload-img" src="'+res.src+'" width="100px"><i class="layui-icon">&#x1006;</i></span>');
                        $('#upload-thumb1').val($('#upload-thumb1').val()+","+res.src);
                    } else {
                        layer.msg(res.msg);
                    }
                }
                ,error: function(){
                    //请求异常回调
                    //演示失败状态，并实现重传
                    layer.closeAll('loading');
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
                ,before:function () {
                    layer.load(2);
                }
            });

            //执行实例视频
            upload.render({
                elem: '#test5'
                ,url: "{:url('common/upload')}"
                ,accept: 'video' //视频
                ,size:'65536'
                ,done: function(res){
                    layer.closeAll('loading');
                    if(res.code == 2) {
                        layer.msg("文件上传成功");
                        $("#seevideo").html('<video controls style="width: 200px">\n' +
                            '<source  src="'+res.src+'">\n' +
                            '</video>');
                        $("#upload-video").val(res.src);
                    } else {
                        layer.msg(res.msg);
                    }
                }
                ,error:function () {
                    layer.closeAll('loading');
                }
                ,before:function () {
                    layer.load(2);
                }
            });

        });
        $("#seeupload1").on("click",".layui-icon",function(){
            $(this).parent().remove();
            thumb("seeupload1",1);
        });
        function thumb(obj,n){
            var thumbs="";
            $("#"+obj).find("img").each(function(){
                var url=$(this).attr("src");
                thumbs+=","+url;
            });
            $("#upload-thumb"+n).val(thumbs);
        }

        //***************************************************************************
        //行程选择
        form.on('select(addTrip)', function(data){
            var tripid=data.value;
            if(tripid!==''){
                $.ajax({
                    url:"{:url('admin/standard/getTripData')}",
                    data:{tripid:tripid},
                    type:'post',
                    async: false,
                    success:function(res) {
                        console.log(res);
                        $("input[name='days']").attr("value",res.days);
                        $("#toursLineTitle").val(res.toursLineTitle);

                        return false;
                    }
                });
                return false;
            }
        });

        //***************************************************************************
        //模糊查询标签list
        var cpLock = true;
        function bindFunc(){
            //解决监听输入时中文输入法问题
            $("#tags").parent().find(".layui-select-title input").on('compositionstart', function () {
                cpLock = false;
            });
            $("#tags").parent().find(".layui-select-title input").on('compositionend', function () {
                cpLock = true;
            });
            $("#tags").parent().find(".layui-select-title input").bind('input propertychange',function(){
                var CityName = $(this).val();
                showTagList(CityName,3);
            });
            //点击时选中文本
            $("#tags").parent().find(".layui-select-title input").attr("onfocus","this.select()");
        }
        bindFunc();
        function showTagList(tagName,tagType){
            setTimeout(function(){
                if (cpLock) {
                        var html="<option value=''>请填写标签</option>";
                        $.ajax({
                            url:"{:url('admin/standard/showTagList')}",
                            data:{'tagName':tagName,tagType:tagType},
                            type:'post',
                            async: false,
                            success:function(data) {
                                console.log(data);
                                for(var i=0;i<data.length;i++){
                                    html += "<option value="+data[i]["tag_id"]+">"+data[i]["tag_name"]+"</option>";
                                }
                                $("#tags").html(html);
                            }
                        });

                        //重新渲染select
                        form.render('select');
                        bindFunc();
                        bindFunc1();
                        bindFunc2();

                        $("#tags").next().addClass("layui-form-selected");
                        $("#tags").next().find(".layui-input").focus();
                        $("#tags").next().find(".layui-input").val(tagName);
                    }
            },1);
        }

        //模糊查询商品list
        var cpLock1 = true;
        function bindFunc1(){
            //解决监听输入时中文输入法问题
            $("#addGoods").parent().find(".layui-select-title input").on('compositionstart', function () {
                cpLock1 = false;
            });
            $("#addGoods").parent().find(".layui-select-title input").on('compositionend', function () {
                cpLock1 = true;
            });
            $("#addGoods").parent().find(".layui-select-title input").bind('input propertychange',function(){
                var GoodsName = $(this).val();
                showGoodsList(GoodsName);
            });
            //点击时选中文本
            $("#addGoods").parent().find(".layui-select-title input").attr("onfocus","this.select()");
        }
        bindFunc1();
        function showGoodsList(GoodsName){
            setTimeout(function(){
                if (cpLock1) {
                        var html="<option value=''>请填写商品名称</option>";
                        $.ajax({
                            url:"{:url('admin/standard/showGoodsList')}",
                            data:{'GoodsName':GoodsName},
                            type:'post',
                            async: false,
                            success:function(data) {
                                console.log(data);
                                for(var i=0;i<data.length;i++){
                                    html += "<option value="+data[i]["goods_id"]+">"+data[i]["goods_id"]+"__"+data[i]["goods_tcode"]+"__"+data[i]["goods_name"]+"</option>";
                                }
                                $("#addGoods").html(html);
                            }
                        });

                        //重新渲染select
                        form.render('select');
                        bindFunc();
                        bindFunc1();
                        bindFunc2();

                        $("#addGoods").next().addClass("layui-form-selected");
                        $("#addGoods").next().find(".layui-input").focus();
                        $("#addGoods").next().find(".layui-input").val(GoodsName);
                    }
            },1);
        }

        //模糊查询行程list
        var cpLock2 = true;
        function bindFunc2(){
            //解决监听输入时中文输入法问题
            $("#addTrip").parent().find(".layui-select-title input").on('compositionstart', function () {
                cpLock2 = false;
            });
            $("#addTrip").parent().find(".layui-select-title input").on('compositionend', function () {
                cpLock2 = true;
            });
            $("#addTrip").parent().find(".layui-select-title input").bind('input propertychange',function(){
                var TripName = $(this).val();
                showTripList(TripName);
            });
            //点击时选中文本
            $("#addTrip").parent().find(".layui-select-title input").attr("onfocus","this.select()");
        }
        bindFunc2();
        function showTripList(TripName){
            setTimeout(function(){
                if (cpLock2) {
                        var html="<option value=''>请填写行程名称</option>";
                        $.ajax({
                            url:"{:url('admin/standard/showTripList')}",
                            data:{'TripName':TripName},
                            type:'post',
                            async: false,
                            success:function(data) {
                                console.log(data);
                                for(var i=0;i<data.length;i++){
                                    html += "<option value="+data[i]["id"]+" city-id='"+data[i]["start_city"]+"'>"+data[i]["id"]+"__"+data[i]["name"]+"</option>";
                                }
                                $("#addTrip").html(html);
                            }
                        });

                        //重新渲染select
                        form.render('select');
                        bindFunc();
                        bindFunc1();
                        bindFunc2();

                        $("#addTrip").next().addClass("layui-form-selected");
                        $("#addTrip").next().find(".layui-input").focus();
                        $("#addTrip").next().find(".layui-input").val(TripName);
                    }
            },1);
        }

        //获取形成简介
        function setTripSummary(trip_id){
            $summary = "";
            if(trip_id!="" && trip!=0 && trip!=undefined){
                $.post("/admin/standard/getTripSummary",{trip_id:trip_id},function(data){
                    console.log(data)
                    if(data.code==1){
                        $("textarea[name=toursLineTitle]").val(data.data.title);
                        if(data.data.city!=null && data.data.city > 0){
                            $("select[name=startCityId]").val(data.data.city);
                            form.render("select");
                        }
                    }
                },"json")
            }

            return $summary;
        }

        //点击行程获取行程简介
        form.on('select(addTrip)',function(data){
            var trip_id = data.value;
            if(trip_id=="" || trip_id==0 || trip_id==undefined){
                return false;
            }else{
                setTripSummary(trip_id);
            }
        })
    });
</script>

<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
//    ue = UE.getEditor('introduce');
</script>
</body>
</html>
